
map $http_upgrade $connection_upgrade {
        default Upgrade;
        '' close;
    }

server {
	listen 80 default_server;
	listen [::]:80 default_server ipv6only=on;

	server_name_in_redirect off;
	
	root /usr/share/nginx/html;
	index index.html index.htm;

	# Make site accessible from http://localhost/
	server_name localhost;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
		# Uncomment to enable naxsi on this location
		# include /etc/nginx/naxsi.rules
	}

	# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
	location /v1/ {
		# set client body size to 500M #
		client_max_body_size 500M;

		proxy_pass http://{{ tomcat_v1 }};
		proxy_set_header Upgrade $http_upgrade;
            	proxy_set_header Connection $connection_upgrade;

            	proxy_http_version 1.1;
            	proxy_set_header X-Real-IP $remote_addr;
            	proxy_set_header Host $host;
            	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            	proxy_redirect   off;
            	break;
	}

	#error_page 404 /404.html;

	# redirect server error pages to the static page /50x.html
	#
	#error_page 500 502 503 504 /50x.html;
	#location = /50x.html {
	#	root /usr/share/nginx/html;
	#}

}


# HTTPS server
#
#server {
#	listen 443;
#	server_name localhost;
#
#	root html;
#	index index.html index.htm;
#
#	ssl on;
#	ssl_certificate cert.pem;
#	ssl_certificate_key cert.key;
#
#	ssl_session_timeout 5m;
#
#	ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
#	ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
#	ssl_prefer_server_ciphers on;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}